package com.sc.nft.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.sc.nft.dao.UserRelevanceDao;
import com.sc.nft.dao.UserWorkRoomDao;
import com.sc.nft.entity.ApplicationRequirement;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.vo.ApplicationRequirementFactoryVO;
import com.sc.nft.enums.ApplicationRequirementEnum;
import com.sc.nft.service.ApplicationRequirementFactoryService;
import com.sc.nft.util.DecideUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 直推交易用户数
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class DirectPushTradingUsersFactoryServiceImpl implements ApplicationRequirementFactoryService {

    private final UserWorkRoomDao userWorkRoomDao;

    private final UserRelevanceDao userRelevanceDao;

    @Override
    public ApplicationRequirementFactoryVO applicationRequirement(UserInfo userInfo, ApplicationRequirement applicationRequirement,Integer type) {
//        DateTime end = DateUtil.yesterday();
//        DateTime start = DateUtil.offsetDay(end,-30);
//        Integer byUserIdAndLvAndNotInRelevanceIdCount = userRelevanceDao.getByUserIdAndLvAndNotInRelevanceIdCount(userInfo.getId(), DateUtil.format(start,"yyyyMMdd") );
//        ApplicationRequirementFactoryVO applicationRequirementFactoryVO = new ApplicationRequirementFactoryVO();
//        applicationRequirementFactoryVO.setKey(StrUtil.format("{}{}{}", applicationRequirement.getType().getDescription(), applicationRequirement.getJudgingCriteria(), applicationRequirement.getValue()));
//        applicationRequirementFactoryVO.setAskForValue(applicationRequirement.getValue());
//        applicationRequirementFactoryVO.setPracticalValue(byUserIdAndLvAndNotInRelevanceIdCount);
//        // 根据compoundMode字段中的 > < >= <= = 五中 来判定是否满足条件
//        applicationRequirementFactoryVO.setSatisfy(DecideUtil.conditionalDecision(byUserIdAndLvAndNotInRelevanceIdCount, applicationRequirement.getValue(), applicationRequirement.getJudgingCriteria()));
//        return applicationRequirementFactoryVO;
        return null;
    }

    @Override
    public Integer code() {
        return ApplicationRequirementEnum.DIRECT_PUSH_TRADING_USERS.getCode();
    }

}
